// WebSocket连接管理
class WebSocketChatManager {
private:
    std::unordered_map<int, WebSocketConnectionPtr> ws_connections_;
    ChatService& chat_service_;
    
public:
    void onWebSocketConnection(const WebSocketConnectionPtr& conn) {
        if (conn->connected()) {
            LOG_INFO << "WebSocket connected from " << conn->peerAddress().toIpPort();
        } else {
            // 处理连接断开
            handleWebSocketClose(conn);
        }
    }
    
    void onWebSocketMessage(const WebSocketConnectionPtr& conn, const string& message) {
        try {
            json js = json::parse(message);
            int msgid = js["msgid"].get<int>();
            
            // 根据消息类型处理
            switch(msgid) {
                case LOGIN_MSG:
                    handleLoginMessage(conn, js);
                    break;
                case ONE_CHAT_MSG:
                    handleOneChatMessage(conn, js);
                    break;
                case GROUP_CHAT_MSG:
                    handleGroupChatMessage(conn, js);
                    break;
                default:
                    LOG_WARN << "Unknown message type: " << msgid;
            }
        } catch (const std::exception& e) {
            LOG_ERROR << "WebSocket message parse error: " << e.what();
        }
    }
};